package cn.tedu.web.stm;

import cn.hutool.captcha.*;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet(urlPatterns = "/stmcode")
public class CaptchaServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        HttpSession session = req.getSession();
        LineCaptcha captcha = CaptchaUtil.createLineCaptcha(114,35,4,20);
//        CircleCaptcha captcha = CaptchaUtil.createCircleCaptcha(100,21);
//        ShearCaptcha captcha = CaptchaUtil.createShearCaptcha(100,21);
//        GifCaptcha captcha = CaptchaUtil.createGifCaptcha(100, 21);
        String code = captcha.getCode();
        session.setAttribute("cun",code);
        captcha.write(resp.getOutputStream());
    }
}
